/**   
* @Title: PoiDriveSegmentListAdapter.java 
* @author zengshuai shi   
* @date 2015年8月4日 下午2:37:33 
*/
package com.shanghaionstar.nav.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.base.CommonAdapter;
import com.onstar.cn.framework.base.CommonViewHolder;
import com.onstar.cn.map.common.DriveSegmentInfo;
import com.shanghaionstar.R;

import java.util.List;

public class PoiDriveSegmentListAdapter extends CommonAdapter<DriveSegmentInfo> {
	private Context mContext;
	private List<DriveSegmentInfo> mDriveSegmentList;
	
	
	public PoiDriveSegmentListAdapter(List<DriveSegmentInfo> datas, Context context) {
		super(datas, context);
		mContext = context;
		mDriveSegmentList = datas;
	}

	@Override
	public void getView(int position, CommonViewHolder viewHolder) {
		ViewHolder holder = (ViewHolder) viewHolder;	
		DriveSegmentInfo driveSegmentInfo = mDriveSegmentList.get(position);
		holder.poi_route_text_id.setText(driveSegmentInfo.getStepedDescription());
        if(position == 0)
        {
            holder.poi_route_detail_image_s.setVisibility(View.VISIBLE);
            holder.poi_route_detail_image.setVisibility(View.GONE);
            holder.poi_route_detail_image_e.setVisibility(View.GONE);
        }
        else if(position == (getCount() - 1))
        {
            holder.poi_route_detail_image_s.setVisibility(View.GONE);
            holder.poi_route_detail_image.setVisibility(View.GONE);
            holder.poi_route_detail_image_e.setVisibility(View.VISIBLE);
        }
        else
        {
            holder.poi_route_detail_image_s.setVisibility(View.GONE);
            holder.poi_route_detail_image.setVisibility(View.VISIBLE);
            holder.poi_route_detail_image_e.setVisibility(View.GONE);
        }
	}

	@Override
	public int layoutId() {
		return R.layout.nav_poi_route_list_item;
	}

	@Override
	public CommonViewHolder getViewHolder() {
		return new ViewHolder();
	}
	private class ViewHolder extends CommonViewHolder {
		@FindViewById
		ImageView poi_route_detail_image,poi_route_detail_image_s,poi_route_detail_image_e;  //zhong jian dian
		@FindViewById
		TextView poi_route_text_id;
	}

}
